<%@ page session="false"%>
<%@ page contentType="text/html;charset=UTF8"%>
<%@page import="java.util.List"%>
<%@page import="net.sureon.biz.GroupBO"%>
<%@page import="net.sureon.web.admin.ManageGroup"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>团队管理</title>
<jsp:include page="../header.jsp" flush="true" />

<style type="text/css">
<!--
.STYLE1 {
	font-size: small
}
-->
</style>
<script type="text/javascript">
	function deleteNullGroup() {
		if(confirm("确认删除团队？")) {
			return true;
		}
			else {
			return false;	
		}
	}

function validateForm(groupForm) {
		if (groupForm.groupName.value == "") {
			alert("团队名称为必填项， 请正确填写.");
			return false;
		}
		if (groupForm.parentGroup.value == "0") {
			alert("上级团队为必选项， 请选择.");
			return false;
		}
		return true;
	}
</script>
</head>
<table cellpadding="0" cellspacing="0" class="style5">
	<tr>
		<td colspan="4" bgcolor="#FFFBD6"><span
			id="ctl00_ContentPlaceHolder1_Label4"
			style="color: #990000; background-color: #FFCC66; font-size: small">团队目录</span>
		</td>
	</tr>
	<tr>
		<td colspan="4">
		<div>
		<table cellspacing="0" cellpadding="4" border="0"
			id="ctl00_ContentPlaceHolder1_GridView1"
			style="color: #333333; width: 100%; border-collapse: collapse; font-size: small; font-family: Arial">
			<tr
				style="color: White; background-color: #507CD1; font-weight: bold;">
				<th scope="col"></th>
				<th scope="col" style="color: White;" align="left">名称</th>
				<th scope="col" style="color: White;" align="left">经理</th>
				<th scope="col" style="color: White;" align="left">团队成员人数</th>
				<th scope="col" style="color: White;" align="left">直接上级团队</th>
				<th scope="col" style="color: White;" colspan="1">操作</th>
			</tr>
 			
			<c:forEach var="group" items="${groups}" varStatus="rowCounter">
				<c:choose>
					<c:when test="${rowCounter.count % 2 == 0}">
						<c:set var="bgColor" scope="page" value="#EFF3FB;" />
					</c:when>
					<c:otherwise>
						<c:set var="bgColor" scope="page" value="#FFFFFF;" />
					</c:otherwise>
				</c:choose>
				<tr style="background-color: ${bgColor}" align="left">
					<td style="width: 20px;"></td>
					<td style="width: 150px;"><c:choose>
						<c:when test='${group.groupBO.groupVO.groupID==1}'>
${group.recusiveGroupName}
</c:when>
						<c:otherwise>
							<a href="manageGroup.do?action=edit&id=${group.groupBO.groupID}">${group.recusiveGroupName}</a>
						</c:otherwise>
					</c:choose></td>
					<td style="width: 50px;">${group.groupManagerName}</td>
					<td style="width: 50px;">${group.groupMemberNum}</td>
					<td style="width: 150px;"><c:choose>
						<c:when test='${group.groupBO.groupVO.groupID==1}'>
N/A
</c:when>
						<c:otherwise>
							${group.parentGroupName}
						</c:otherwise>
					</c:choose></td>
					<td style="width: 50px;">
					<c:choose>
					<c:when test="${group.nullGroup == true}">
						<a href="manageGroup.do?action=delete&id=${group.groupBO.groupID}" onclick="return deleteNullGroup();">删除</a>
					</c:when>
					<c:otherwise>
						删除
					</c:otherwise>
				</c:choose>
					</td>
				</tr>
			</c:forEach>
		</table>
		</div>
		</td>
	</tr>
 
	<tr>
		<td colspan="4" style="text-align: center; font-size: small; color: red">
<%
					if(request.getAttribute("alreadyGroupManager") != null) {
				%>	
	<%=request.getAttribute("alreadyGroupManager") %>
				<%	
					}
				 %>
	

</td>
	</tr>
	<form:form id="groupForm" name="groupForm" commandName="groupForm"
		onsubmit="return validateForm(this);">
		<tr>
			<td colspan="4" bgcolor="#FFFBD6"><span
				id="ctl00_ContentPlaceHolder1_Label5"
				style="color: #990000; background-color: #FFCC66; font-size: small">信息维护</span>
			<form:errors path="*" /> ${errors.errorCount}</td>
		</tr>
		<tr>
			<td style="text-align: right; font-size: small">团队名称(*)：</td>
			<td><form:input path="groupName"
				cssStyle="height: 16px; width: 200px;" /></td>
			<td style="text-align: right; font-size: small">上级团队(*)：</td>
			<td>
			<form:select path="parentGroup"
				cssStyle="height: 23px; width: 120px;">
				<form:option value="0" label="----请选择----" />
				<form:options items="${groupForm.groupList}" itemValue="groupBO.groupID"
					itemLabel="recusiveGroupName" />
			</form:select>
			</td>
		</tr>
		<tr>
			<td style="text-align: right; font-size: small">经理：</td>
			<td>
					<form:select path="groupManager"
						cssStyle="height: 23px; width: 120px;">
						<form:option value="0" label="----请选择----" />
						<form:options items="${groupForm.groupManagerList}"
							itemValue="groupManager" itemLabel="groupManagerName" />
					</form:select>
				</td>
				
			<td colspan="3"/>
		</tr>
		<c:if test='${groupForm.groupName != null}'>
			<form:hidden path="groupID" />
		</c:if>
		<tr>
			<td colspan="4" style="text-align: center">&nbsp; <input
				type="submit" name="submit"
				value="<c:choose><c:when test='${groupForm.groupID > 0}'>更新团队</c:when><c:otherwise>创建团队</c:otherwise></c:choose>"
				id="ctl00_ContentPlaceHolder1_Button6" /> &nbsp; <input
				type="button" name="clear" value="清空表格" id="clear"
				onClick="location.href='manageGroup.do'" /></td>
		</tr>
	</form:form>
	
</table>
</td>
</tr>
</table>
<jsp:include page="../footer.jsp"></jsp:include>
</body>
</html>
